package com.assignwork.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springblade.core.tool.utils.Func;

import java.math.BigDecimal;
import java.util.List;

@Data
public class StatisticsThroughputForecastVO {

    public static final String[] CN_MONTH = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"};

    private String endTime;
    private String endTimeName;
//    private String planDate;
    private String periodTenDays;
    private String periodTenDaysName;
    private String cargoType;
    private String cargoTypeName;
    private String tradeType;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long shipowner;
    private String shipownerName;
    private String impExp;
    private BigDecimal totalTon;
    private BigDecimal iTon;
    private BigDecimal oTon;
    private BigDecimal oiTon;
    private BigDecimal oeTon;
    private BigDecimal iiTon;
    private BigDecimal ieTon;

    private List<StatisticsThroughputForecastVO> subset;

    public String getEndTimeName() {
        if (Func.isNotBlank(endTime)) {
            String[] split = endTime.split("-");
            if (split.length >= 2) {
                return CN_MONTH[Func.toInt(split[1]) - 1] + "月";
            } else if (split[0].length() <= 2) {
                return CN_MONTH[Func.toInt(split[0]) - 1] + "月";
            } else {
                return endTime;
            }

        }
        return endTimeName;
    }

    public String getTotalTonStr() {
        if (totalTon != null) {
//            return totalTon.stripTrailingZeros().toPlainString();
            return totalTon.intValue() + "";
        }
        return "";
    }

    public String getiTonStr() {
        if (iTon != null) {
//            return iTon.stripTrailingZeros().toPlainString();
            return iTon.intValue() + "";
        }

        return "";
    }

    public String getoTonStr() {
        if (oTon != null) {
//            return oTon.stripTrailingZeros().toPlainString();
            return oTon.intValue() + "";
        }
        return "";
    }

    public String getOiTonStr() {
        if (oiTon != null) {
//            return oiTon.stripTrailingZeros().toPlainString();
            return oiTon.intValue() + "";
        }
        return "";
    }

    public String getOeTonStr() {
        if (oeTon != null) {
//            return oeTon.stripTrailingZeros().toPlainString();
            return oeTon.intValue() + "";
        }
        return "";
    }

    public String getIiTonStr() {
        if (iiTon != null) {
//            return iiTon.stripTrailingZeros().toPlainString();
            return iiTon.intValue() + "";
        }
        return "";
    }

    public String getIeTonStr() {
        if (ieTon != null) {
//            return ieTon.stripTrailingZeros().toPlainString();
            return ieTon.intValue() + "";
        }
        return "";
    }

}
